const { Sequelize } = require("sequelize");
const UserModel = require("../models/user");
const PostModel = require("../models/post");
const CommentModel = require("../models/comment");
const TagModal = require("../models/tag");
const CategoryModal = require("../models/category");

const sequelize = new Sequelize("blog-admin", "root", "771122spc", {
  host: "localhost",
  dialect: "mysql",
  port: 3306,
  logging: false, // Disable logging
});

const User = UserModel(sequelize); // 用户表
const Category = CategoryModal(sequelize); // 类别表
const Post = PostModel(sequelize); // 文章表
const Comment = CommentModel(sequelize); // 评论表
const Tag = TagModal(sequelize); // 标签表

// 同步所有模型到数据库
module.exports = { sequelize, User, Post, Comment, Tag, Category };
